﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.ViewModel;
using System.IO;
using System.Reflection;

namespace Hockey.UILayer.ViewModels
{
    /// <summary>
    /// License dialog ViewModel
    /// </summary>
    public class LicensesVM: NotificationObject
    {
        private LicensesParser _parser;

        public LicensesVM()
        {
            // get app path and load licenses
            string appPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            Load(appPath);
        }

        #region Binding Properties

        public string ProgramName
        { get; set; }

        public string URLTitle
        { get; set; }

        public Uri URLNavigation
        { get; set; }

        public List<LibraryRecord> Libraries
        { get; set; }
        
        #endregion

        private void Load(string sAppPath)
        {
            _parser = new LicensesParser(sAppPath);
            _parser.Parse();

            ProgramName = _parser.ProgramName;
            URLTitle = _parser.ProgramURL;
            URLNavigation = new Uri(_parser.ProgramURL);
            Libraries = _parser.LibraryRecords;
        }

    }
}
